package com.example.hellowordl;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;

public class HomeActivity extends AppCompatActivity {

    private static final String TAG = "Lifecycle_Home";

    private static final String YOUR_NAME = "王新";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        Log.d(TAG, "onCreate - " + YOUR_NAME + " - 活动正在被创建");

        Button buttonLogout = findViewById(R.id.button_logout);
        buttonLogout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(HomeActivity.this, LoginActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.d(TAG, "onStart - " + YOUR_NAME + " - 活动即将可见");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d(TAG, "onResume - " + YOUR_NAME + " - 活动已可见，并获得焦点");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d(TAG, "onPause - " + YOUR_NAME + " - 活动即将暂停，失去焦点");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d(TAG, "onStop - " + YOUR_NAME + " - 活动完全不可见");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy - " + YOUR_NAME + " - 活动即将被销毁");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.d(TAG, "onRestart - " + YOUR_NAME + " - 活动正在从停止状态重新启动");
    }
}